package com.kotlin.jetpack.android.push

import android.content.Context
import android.text.TextUtils
import cn.jpush.android.api.NotificationMessage
import cn.jpush.android.service.JPushMessageReceiver
import com.kotlin.android.core.ext.putSpValue
import com.kotlin.android.ktx.ext.KEY_JPUSH_ID
import com.kotlin.android.ktx.ext.d

/**
 * 创建者: zl
 * 创建时间: 2020/5/19 8:53 AM
 * 描述:
 */
class JPushReceiver : JPushMessageReceiver() {
    override fun onRegister(p0: Context?, p1: String?) {
        super.onRegister(p0, p1)
        "onRegister-> $p1".d()
        if (!TextUtils.isEmpty(p1)) {
            putSpValue(KEY_JPUSH_ID, p1)
        }
    }

    override fun onNotifyMessageArrived(p0: Context?, p1: NotificationMessage?) {
        super.onNotifyMessageArrived(p0, p1)
        "onNotifyMessageArrived-> $p1".d()

    }

    override fun onNotifyMessageOpened(p0: Context?, p1: NotificationMessage?) {
        super.onNotifyMessageOpened(p0, p1)
        "onNotifyMessageOpened-> $p1".d()


    }
}